﻿@using System.Xml.Linq

<ul>
@if(String.IsNullOrWhiteSpace(Model.Error))
{
    var xReport = Model.Data as XElement;
    var data = xReport != null && xReport.HasElements
        ? xReport.Elements("entry").Select(x => new
        {
            username = x.Attribute("accountUsername").Value,
            accountID = x.Attribute("accountID").Value.ParseAs<Int32>(),
            karma = x.Attribute("karmaPoints").Value.ParseAs<Int32>()
        })
        : null;
    if(data != null && data.Any())
    {
        foreach(var i in data)
        {
            <li>
                <a href="@Url.Action(Loc.Act("Show").Ctrl("Account").NoArea().Set(new
                {
                    id = i.accountID
                }).Localized())">@i.username</a><span class="footnote">(@i.karma)</span>
            </li>
        }
    }
    else
    {
        <li class="empty"><span>@T(Res.In("Common").Of("Expr").Name("NoData"))</span></li>
    }
}
else
{
    <li class="error">@Model.Error</li>
}
</ul>
